home *** CD-ROM | disk | FTP | other *** search
- /********************************************************************
- * *
- * Sizing fixing and positioning routine *
- * *
- * Copyright (C) 1993 - 1994, BitGate Software and Clever Bits. *
- * All Rights Reserved. *
- * *
- * The revolutionary sizing fix that was desperately needed with *
- * WinLIB PRO. These routines fix the position of 3D objects (as *
- * a result of object fixing, it's a GEM bug), and they also fix *
- * object sizes for higher resolutions (one file, many resolutions)*
- * *
- ********************************************************************
- * *
- * Update log: *
- * *
- * [15.12.93 - 29.3.94] Ken Hollis *
- * position_fix - added for position fixing of root objects *
- * - worked on sizing routine *
- * - tried out Markus Gutschke's sizing routs *
- * - fixed for children with 3D parents *
- * - added additional fix for 3D menu bars *
- * - fixed MENULINE type for 3D menu bars *
- * - added fix for TITLES and their siblings *
- * - fixed 3D boxes from TITLES... Weird... *
- * - made safer and secure for non-3D menus *
- * - added thickness check for fixes *
- * - added fix for any unfixed objects *
- * *
- ********************************************************************/
-
- #include "winlib.h"
-
- #ifndef __SIZING__
- #define __SIZING__
- #endif
-
- /*
- * Fix rooted object coordinates
- *
- * Since we had a sizing problem, the main problem was with the
- * objects that had multiple roots; these objects had to be moved
- * down one and to the right one since they were modified. If you
- * have more than one root without this fix, things get hectic, as
- * you might imagine. It's just a simple problem that was easily
- * fixed, thanks to Markus Gutschke's help...
- */
- GLOBAL void position_fix(OBJECT *obj)
- {
- int object = 1, objc, parent;
- int i, j, x, y, w, h, x1, y1;
- BOOL menu = FALSE;
-
- do {
- if (obj[object++].ob_type == G_TITLE)
- menu = TRUE;
- } while(!(obj[object].ob_flags & LASTOB));
-
- object = 1;
-
- if (!menu) {
- do {
- object++;
- parent = object;
- if ((obj[parent].ob_state & DRAW3D) && !(obj[parent].ob_state & ALREADYMOD)) {
- for (objc = obj[parent].ob_head; objc>=0 && objc!=parent; objc = obj[objc].ob_next) {
- if ((obj[parent].ob_state & DRAW3D) && (objc!=1)) {
- if (!(obj[objc].ob_state & ALREADYMOD)) {
- EXTINFO *ex = obj[parent].ob_spec.userblk->ub_parm;
-
- if (ex->te_thickness < 0) {
- obj[objc].ob_x += (abs(ex->te_thickness));
- obj[objc].ob_y += (abs(ex->te_thickness));
- obj[objc].ob_state |= ALREADYMOD;
- }
- }
- }
- }
-
- while(parent >= 0) {
- objc = parent;
- parent = -1;
-
- i = objc;
-
- do {
- if ((obj[parent].ob_state & DRAW3D) && (i!=1)) {
- EXTINFO *ex = obj[parent].ob_spec.userblk->ub_parm;
-
- if (!(obj[i].ob_state & ALREADYMOD)) {
- if (ex->te_thickness < 0) {
- obj[i].ob_x += (abs(ex->te_thickness));
- obj[i].ob_y += (abs(ex->te_thickness));
- obj[i].ob_state |= ALREADYMOD;
- }
- }
- }
-
- if ((j = obj[i].ob_next) >= 0 && obj[j].ob_tail == i) {
- parent = j;
- i = obj[j].ob_head;
- } else
- i = j;
- } while(i>=0 && i!=objc);
- }
- }
- } while(!(obj[object].ob_flags & LASTOB));
- }
-
- if ((obj[object].ob_flags & LASTOB) &&
- !(obj[object].ob_state & ALREADYMOD) &&
- (obj[object].ob_state & DRAW3D) &&
- !(menu)){
- obj[object].ob_x++;
- obj[object].ob_y++;
- }
-
- object = 2;
-
- if ((menu) && (obj[1].ob_state & DRAW3D)) {
- obj[0].ob_state |= ALREADYMOD; /* Desktop size */
- obj[1].ob_state |= ALREADYMOD; /* Menu bar drawing line */
- obj[2].ob_state |= ALREADYMOD; /* Object holding titles */
-
- do {
- object++;
- parent = object;
- if (!(obj[parent].ob_state & ALREADYMOD)) {
- for (objc = obj[parent].ob_head; objc>=0 && objc!=parent; objc = obj[objc].ob_next) {
- if (objc!=1) {
- if (!(obj[objc].ob_state & ALREADYMOD) && (obj[parent].ob_type != G_TITLE)) {
- obj[objc].ob_x++;
- obj[objc].ob_y++;
- obj[objc].ob_state |= ALREADYMOD;
- }
- }
- }
-
- while(parent >= 0) {
- objc = parent;
- parent = -1;
-
- i = objc;
-
- do {
- if ((obj[parent].ob_type != G_TITLE) && (i!=1)) {
- if (!(obj[i].ob_state & ALREADYMOD)) {
- obj[i].ob_x++;
- obj[i].ob_y++;
- obj[i].ob_state |= ALREADYMOD;
- }
- }
-
- if ((j = obj[i].ob_next) >= 0 && obj[j].ob_tail == i) {
- parent = j;
- i = obj[j].ob_head;
- } else
- i = j;
- } while(i>=0 && i!=objc);
- }
- }
- } while (!(obj[object].ob_flags & LASTOB));
- }
-
- object = 2;
- while (!(obj[object].ob_flags & LASTOB)) {
- if ((!(obj[object].ob_state & ALREADYMOD)) &&
- (obj[object].ob_state & DRAW3D)) {
- obj[object].ob_x++;
- obj[object].ob_y++;
- obj[object].ob_state |= ALREADYMOD;
- }
-
- object++;
- }
-
- object = 0;
- while (!(obj[object].ob_flags & LASTOB)) {
- if (obj[object].ob_state & ALREADYMOD)
- obj[object].ob_state &= ~ALREADYMOD;
- if (menu && (obj[object].ob_type == G_TITLE) && (obj[1].ob_state & DRAW3D)) {
- obj[object].ob_x--;
- obj[object].ob_y--;
- }
- object++;
- }
-
- object = 3;
-
- while (!(obj[object].ob_flags & LASTOB)) {
- if (menu) {
- if (obj[object].ob_state & DRAW3D) {
- EXTINFO *ex = (EXTINFO *) obj[object].ob_spec.userblk->ub_parm;
-
- if ((ex->oldtype == G_BOX) ||
- (ex->oldtype == G_IBOX)) {
- obj[object].ob_x -= 2;
- obj[object].ob_y -= 2;
- }
- }
- }
-
- object++;
- }
- }